<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of personal_model
 *
 * @author Neil
 */
class cliente_model extends CI_Model {

    public function Cliente() {
        $query = $this->db->get('cliente');
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }

    public function regMod($codigo, $data) {
        if ($codigo == '') {
            $this->db->insert('cliente', $data);

            $query = $this->db->query('SELECT max(cod_cli) as codCli FROM cliente');
            return $query->result_array();
        } else {
            $this->db->where('cod_cli', $codigo);
            $this->db->update('cliente', $data);

            return $codigo;
        }
    }

    public function listarxCod($cod) {
        $query = $this->db->query('SELECT * FROM cliente where cod_cli=?', $cod);
        return $query->result();
    }

    public function BuscarxDNI($dni) {
        $query = $this->db->query('SELECT * FROM cliente where dni=?', $dni);
        return $query->result();
    }

}

?>
